<template>
    <div>
        <h1 style="text-align: left;">员工薪资结构</h1><br>
        
        <el-form :model="formData" ref="form" :rules="rules" label-width="80px" :inline="true" style="display: flex; flex-direction: column; gap: 16px; text-align: left;">
            
            <el-form-item label="">
                
                <el-row :gutter="20" style="width: 100%;">
                    <el-col :span="12" :offset="0">
                        <span>员工姓名</span>
                        <el-input v-model="formData.emp"></el-input>
                        <span>岗位</span>
                        <el-input v-model="formData.postsName"></el-input>
                        <span>岗位工资（元）</span>
                        <el-input v-model="formData.baseSalary"></el-input>
                        <span>补贴（元）</span>
                        <el-input v-model="formData.subsidy"></el-input>
                    </el-col>
                    <el-col :span="12" :offset="0">
                        <span>所在部门</span >
                        <el-input v-model="formData.departmental"></el-input>
                        <span>状态<br></br></span>
                         <el-radio-group v-model="formData.state">
                       <el-radio label="有效" value="有效">有效</el-radio>
                        <el-radio label="无效" value="无效">无效</el-radio>
        
      </el-radio-group>
                        <span><br></br>绩效薪资（元）</span>
                        <el-input v-model="formData.paySalary"></el-input>
                        <span><br></br>基本工资（元）</span>
                        <el-input v-model="formData.baSa"></el-input>
                    </el-col>                       
                </el-row>
                
                       
                                
            </el-form-item>
            <el-form-item  style="margin-top: auto; align-self: flex-start;">
                <el-button type="primary" @click="onSubmit">提交</el-button>
                
            </el-form-item>
        </el-form>
        
        
    </div>
</template>

<script setup>
import { ref,defineEmits } from 'vue';
import request from '@/api/request.js'

let emits=defineEmits(['ref-table'])
let props=defineProps(["data"])

let formData = ref({
    ...props.data,
    state: props.data?.state !== undefined ? String(props.data.state) : '有效'
})
const onSubmit = () => {
    // 复制表单数据，避免直接修改原始响应式对象
    const submitData = { ...formData.value };
    // 删除emp属性，不传递该字段
    delete submitData.emp;
    
    request({
        url: '/salary/setup/empdisposition/update',
        method: 'put',
        data: submitData  // 使用删除emp后的对象提交
    }).then(res => {
        emits('ref-table');//刷新列表
    })
}
</script>

<style scoped>

</style>
